home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_349 / med / source / med200src.zoo / med-player.a < prev    next >
Text File  |  1990-04-03  |  28KB  |  1,018 lines

  1. ;    MED - by Teijo Kinnunen, 1989, 1990
  2. ;    med-player.a    - the player routine
  3. custom    EQU    $dff000
  4. dmacon    EQU    $096
  5. aud0    EQU    $0A0
  6. aud1    EQU    $0B0
  7. aud2    EQU    $0C0
  8. aud3    EQU    $0D0
  9. ac_ptr    EQU    $00
  10. ac_len    EQU    $04
  11. ac_per    EQU    $06
  12. ac_vol    EQU    $08
  13.         xdef    _GetSerial
  14.         xdef    _FreeSerial
  15.         xdef    _AddMIDIData
  16.         xdef    _AudioInit
  17.         xdef    _AudioRem
  18.         xdef    _ChannelOff
  19.         xdef    _SetTempo
  20.         xref    _tamakappale
  21.         xref    _PiirraPylvas
  22.         xref    _soitin
  23.         xref    _aanipaalla
  24.         xref    _zeroptr
  25.         xref    _periodit
  26.         xref    _specialupd
  27.         xref    _counter
  28.         xref    DrawEqualizer
  29.  
  30.         section    "text",code
  31.         EVEN
  32.         dc.b    ' MEDPlayer is here!!!:'
  33. waithwnum:    dc.l    500
  34. newaptr:    dc.l    0,0,0,0
  35. newalen:    dc.w    0,0,0,0
  36. audaddr:    dc.l    custom+aud0,custom+aud1,custom+aud2,custom+aud3
  37.  
  38. _ChannelOff:    ;d0 = channel #
  39.         lea    prevmidinote,a0    ;first: is it MIDI??
  40.         move.b    0(a0,d0.w),d1
  41.         beq.s    notcomidi    ;not midi note
  42.         clr.b    0(a0,d0.w)
  43.         clr.l    noteondata    ; new midi msg
  44.         move.b    d1,noteondata+1
  45.         lea    prevmidichan,a0
  46.         move.b    0(a0,d0.w),noteondata    ;prev midi channel
  47.         or.b    #$80,noteondata        ;note off
  48.         lea    noteondata,a0
  49.         moveq.l    #3,d0
  50.         bra.w    _AddMIDIData
  51. notcomidi:    cmp.b    #4,d0
  52.         bge.s    notamigatrk
  53.         moveq.l    #1,d1
  54.         lsl.w    d0,d1
  55.         move.w    d1,$dff096
  56. notamigatrk:    rts
  57. _SoitaNuotti:    ;d0 = trk #, d1 = note #, d2 = vol, d3 = instr #
  58.         movem.l    a2-a3/d3-d7,-(sp)    ;All right, let's start!!
  59.         move.w    d2,-(sp)
  60.         clr.l    d4
  61.         bset    d0,d4    ;d4 is mask for this channel
  62.         lea    _soitin,a0        ;Is this instrument in mem?
  63.         lsl.w    #2,d3            ;d3 = instr.num << 2
  64.         tst.l    0(a0,d3.w)
  65.         bne.s    inmem
  66.         lsr.w    #2,d3
  67.         lea    _tamakappale+1574,a0
  68.         tst.b    0(a0,d3.w)        ;is MIDI channel set
  69.         beq.w    retsn2            ; NO!!!
  70.         lsl.w    #2,d3
  71. inmem:        lsr.w    #1,d3            ;d3 = instr. num << 1
  72.         lea    _aanipaalla,a0        ;Is this track on??
  73.         lsl.w    #1,d0            ;d0 = track num << 1
  74.         tst.w    0(a0,d0.w)
  75.         beq.w    retsn2            ; NO!!!!!!
  76.         lsr.w    #1,d0
  77.         add.b    _tamakappale+1550,d1    ;add play transpose
  78.         bgt.s    notenot2low
  79.         add.b    #12,d1    ;note was too low, octave up
  80.         bra.s    endpttest
  81. notenot2low:    cmp.b    #63,d1
  82.         ble.s    endpttest
  83.         sub.b    #12,d1    ;note was too high, octave down
  84. endpttest:    jsr    DrawEqualizer(pc)
  85.         cmp.b    #4,d0
  86.         bge.s    nodmaoff    ;track # >= 4: not an Amiga channel
  87.         move.w    d4,$dff096        ;stop this channel (dmacon)
  88. nodmaoff:    lea    prevmidinote,a0
  89.         move.b    0(a0,d0.w),d6        ;get prev. midi note
  90.         beq.s    noprevmidi
  91.         clr.b    0(a0,d0.w)
  92.         move.b    d6,noteondata+1
  93.         lea    prevmidichan,a0
  94.         move.b    0(a0,d0.w),noteondata    ;prev midi channel
  95.         or.b    #$80,noteondata        ;note off
  96.         lea    noteondata,a0
  97.         clr.b    2(a0)        ;clear volume
  98.         movem.l    d0-d1,-(sp)
  99.         moveq.l    #3,d0
  100.         bsr.w    _AddMIDIData
  101.         movem.l    (sp)+,d0-d1
  102. noprevmidi:    lea    _tamakappale+1574,a1
  103.         lsr.w    #1,d3
  104.         tst.b    0(a1,d3.w)
  105.         bne.w    handleMIDInote
  106.         cmp.b    #4,d0        ;test track # again
  107.         bge.w    retsn2        ;no Amiga instruments in tracks > 3
  108.         or.w    d4,dmaonmsk
  109.         subq.b    #1,d1
  110.         lsl.w    #1,d0
  111.         lsl.w    #1,d3
  112.         lea    newalen(pc),a2
  113.         clr.w    0(a2,d0.w)
  114.         move.w    d0,d6
  115.         lsl.w    #1,d6            ;d6 = channel num << 2
  116.         move.w    d3,d7
  117.         lsl.w    #1,d7            ;d7 = instr. num << 2
  118.         lea    audaddr,a1
  119.         movea.l    0(a1,d6.w),a1    ;base of this channel's regs
  120.         lea    newaptr(pc),a3        ;a3 = address of newaptr
  121.         lea    _soitin,a2        ;get the address of...
  122.         move.l    0(a2,d7.w),d5        ;...this instrument
  123.         move.l    d5,a0
  124.         bsr.w    getinsdata
  125.         move.l    d0,ac_ptr(a1)        ;put it in ac_ptr
  126.         cmp.w    #2,d3
  127.         bls.s    norepeat
  128.         
  129.         add.l    d2,d0        ;d0 = starting address of repeat
  130.         move.l    d0,0(a3,d6.w)    ;remember!! (move to newaptr)
  131.         lsr.w    #1,d3        ;shift right
  132.         lsr.w    #1,d6
  133.         move.w    d3,16(a3,d6.w)    ;remember too (newalen)
  134.         lsr.w    #1,d2        ;shift
  135.         beq.s    begin0        ;rep. start < 2
  136.         move.w    d2,ac_len(a1)    ;move repeat to hardware
  137.         bra.s    retsn1
  138. begin0:        move.w    d3,ac_len(a1)
  139.         bra.s    retsn1
  140.                 
  141. norepeat:    move.l    _zeroptr,0(a3,d6.w)    ;pointer of zero word
  142.         lea    newalen(pc),a3
  143.         lsr.w    #1,d6
  144.         move.w    #1,0(a3,d6.w)        ;length: 1 word
  145.         lsr.l    #1,d1            ;shift length right
  146.         move.w    d1,ac_len(a1)        ;and put to custom chip
  147.  
  148. retsn1:        move.w    d5,ac_per(a1)    ;getinsdata puts period to d5
  149.         lea    prevper(pc),a0
  150.         move.w    d5,0(a0,d6.w)
  151.         move.w    (sp),ac_vol(a1)        ;volume
  152.         lsr.w    #2,d7        ;d7 is now instr. number again
  153. drawcol:    move.w    d7,d0        ;to d0
  154.         subq.w    #1,d0        ;number of column
  155.         clr.l    d1
  156.         move.w    (sp),d1        ;volume (height) to d1
  157.         lsr.b    #1,d1        ;to range 0 - 32
  158.         and.b    #$fe,d1        ;must be even
  159.         beq.s    nodraw        ;volume = 1, don't draw
  160.         jsr    _PiirraPylvas(pc)    ;draw it
  161. nodraw:        move.b    _tamakappale+1551,d0    ;flags
  162.         btst    #1,d0            ;jumping ??
  163.         beq.s    retsn2            ;no...
  164.         btst    #2,d0            ;with instruments
  165.         bne.s    retsn2            ;no......
  166.         move.l    _tamakappale+1554,d0    ;yes!!!, get instr. mask
  167.         lsr.l    d7,d0            ;set this instr. to bit #0
  168.         btst    #0,d0            ;and test it
  169.         beq.s    retsn2            ;no jump with this instr
  170.         move.b    #1,animcnt        ;init animation counter
  171. retsn2:        addq.l    #2,sp    ;forget volume
  172.         movem.l    (sp)+,a2-a3/d3-d7
  173.         rts
  174.  
  175. handleMIDInote:
  176.         add.b    #23,d1        ;2 octaves higher and -1
  177.         move.b    d1,noteondata+1    ;MIDI msg note #
  178.         lea    prevmidinote(pc),a0
  179.         move.b    d1,0(a0,d0.w)    ;save this note number
  180.         move.b    d2,d4        ;temporary save the volume
  181.         subq.b    #1,d2        ;if 64 => 63
  182.         lsl.b    #1,d2        ;volume 0 - 63 => 0 - 127
  183.         bclr    #7,d2        ;be sure that bit 7 is clear
  184.         move.b    d2,noteondata+2    ;MIDI msg volume
  185.         clr.w    d1
  186.         move.b    0(a1,d3.w),d1    ;get midi chan of this instrument
  187.         subq.b    #1,d1        ;from 1-16 to 0-15
  188.         lea    prevmidichan(pc),a0
  189.         move.b    d1,0(a0,d0.w)    ;save to prev midi channel
  190.         move.b    #$90,noteondata    ;MIDI: Note on
  191.         or.b    d1,noteondata    ;MIDI msg Note on & channel
  192.         move.b    32(a1,d3.w),d2    ;get preset #
  193.         beq.s    nochgpres    ;zero = no preset
  194.         lea    prevmchpreset(pc),a0
  195.         move.b    0(a0,d1.w),d0
  196.         cmp.b    d2,d0        ;is this previous preset ??
  197.         beq.s    nochgpres    ;yes...no need to change
  198.         move.b    #$c0,preschgdata
  199.         or.b    d1,preschgdata
  200.         move.b    d2,0(a0,d1.w) ;save preset to prevmchpreset
  201.         subq.b    #1,d2
  202.         move.b    d2,preschgdata+1
  203.         lea    preschgdata,a0
  204.         moveq.l    #5,d0
  205.         bra.s    preschanged
  206. nochgpres:    moveq.l    #3,d0
  207.         lea    noteondata,a0
  208. preschanged:    bsr.w    _AddMIDIData
  209.         move.w    d3,d7
  210.         bra.w    drawcol
  211.  
  212. _StartDMA:        ;This small routine turns on audio DMA
  213.         move.w    dmaonmsk,d0    ;dmaonmsk contains the mask of
  214.         beq.s    retsdma    ;the channels that must be turned on
  215.         bset    #15,d0    ;DMAF_SETCLR: set these bits in dmacon
  216.         move.l    waithwnum,d1
  217. waithw0:    dbf    d1,waithw0
  218.         move.w    d0,custom+dmacon    ;do that!!!
  219.         move.l    waithwnum,d1
  220. waithw1:    dbf    d1,waithw1
  221.         lsr.b    #1,d0    ;finally, push new ptrs to audio hw regs
  222.         bcc.s    pushch1
  223.         move.l    newaptr(pc),custom+aud0+ac_ptr
  224.         move.w    newalen(pc),custom+aud0+ac_len
  225. pushch1:    lsr.b    #1,d0
  226.         bcc.s    pushch2
  227.         move.l    newaptr+4(pc),custom+aud1+ac_ptr
  228.         move.w    newalen+2(pc),custom+aud1+ac_len
  229. pushch2:    lsr.b    #1,d0
  230.         bcc.s    pushch3
  231.         move.l    newaptr+8(pc),custom+aud2+ac_ptr
  232.         move.w    newalen+4(pc),custom+aud2+ac_len
  233. pushch3:    lsr.b    #1,d0
  234.         bcc.s    retsdma
  235.         move.l    newaptr+12(pc),custom+aud3+ac_ptr
  236.         move.w    newalen+6(pc),custom+aud3+ac_len
  237. retsdma:    rts
  238.  
  239.         xref    _mouse1
  240.         xref    _mouse2
  241.         xref    _mouse3
  242.         xref    _mouse4
  243.         xref    _mouse5
  244. frame:    dc.l    0,_mouse2,_mouse3,_mouse4,_mouse5,_mouse5,_mouse4,_mouse3
  245.     dc.l    _mouse2,_mouse1,0
  246. dmaonmsk:    dc.w    0
  247. animcnt:    dc.b    0,0
  248. prevmidinote:    dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  249. prevmidichan:    dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  250. prevpitchbend:    dc.w    $2000,$2000,$2000,$2000,$2000,$2000,$2000,$2000
  251.         dc.w    $2000,$2000,$2000,$2000,$2000,$2000,$2000,$2000
  252. prevmchpreset:    dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;previous preset
  253. prevper:    dc.w    0,0,0,0
  254. prevnote:    dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  255. previnstr:    dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  256. prevvol:    dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  257. effect:        dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  258. effectqual:    dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  259. nextblock:    dc.b    0
  260. animpause:    dc.b    1
  261. numtracks:    dc.b    0,0
  262.         xref    _soittotila
  263.         xref    _soittolohko
  264.         xref    _lohko
  265.         xref    _soittorivi
  266.         xref    _soittolohkonnum
  267.         xref    _lohkoja
  268.         xref    _naytonpaivitys
  269.         xref    _maintsk
  270.         xref    _nayttomsk
  271.         xref    _tempo
  272.         xref    _sprptr
  273.         xref    _hyppymsk
  274.         xref    _komento
  275. _IntHandler:
  276.         movem.l    d2-d7/a2-a4,-(sp)
  277.         cmp.w    #5,_komento ;Do we have to play note from keyboard
  278.         bne.s    nokbnote    ;no...just normal playing
  279.         lea    _komento,a1    ;get the address of the structure
  280.         lea    _tamakappale+1284,a2    ;and the song
  281.         clr.w    dmaonmsk
  282.         clr.w    d0
  283.         clr.w    d1
  284.         move.b    8(a1),d0    ;get all these values from
  285.         move.b    5(a1),d1    ;the command structure
  286.         move.w    6(a1),d3
  287.         clr.w    d2
  288.         move.b    0(a2,d3.w),d2
  289.         clr.w    (a1)        ;clear the command word
  290.         bsr    _SoitaNuotti    ;and play the note finally
  291.         bsr    _StartDMA
  292.         bra.s    notplaying    ;exit
  293. nokbnote:    tst.w    _soittotila    ;are we playing
  294.         bne.s    playing        ;yes, we are
  295.         bclr.b    #0,$bfee01    ;no...stop the timer
  296.         move.b    #$05,_counter
  297.         clr.b    animcnt
  298.         move.l    frame+36,_sprptr
  299.         bra.w    sigjump
  300. notplaying:    movem.l    (sp)+,d2-d7/a2-a4    ;exit interrupt
  301.         rts
  302. playing:    clr.w    dmaonmsk
  303.         add.b    #1,_counter
  304.         cmp.b    #6,_counter    ;if counter = 6: new note and fx
  305.         bne.w    nonewnote    ;if counter is not 6: just do fx
  306.         clr.b    _counter        ;new note!!!
  307.         clr.l    d7        ;number of track
  308.         lea    _lohko,a2    ;a2 = address of 1st block's address
  309.         move.w    _soittolohko,d2
  310.         lsl.w    #2,d2        ;shift to longword index
  311.         movea.l    0(a2,d2.w),a2    ;get the pointer of the block
  312.         move.b    (a2),numtracks+1    ;save # of tracks
  313.         addq.l    #4,a2        ;skip...
  314.         move.w    numtracks,d3
  315.         mulu    #3,d3
  316.         move.w    _soittorivi,d2
  317.         mulu    d2,d3
  318.         adda.l    d3,a2        ;a2 = address of this line
  319.         lea    prevnote(pc),a3
  320.         lea    _tamakappale,a4
  321. trloop0:    clr.w    d5
  322.         move.b    (a2)+,d5    ;get the number of this note
  323.         move.b    (a2)+,d6    ;and the 4 numbers containing fx
  324.         lsl.w    #8,d6
  325.         move.b    (a2)+,d6
  326.         lea    effectqual(pc),a1
  327.         move.b    d6,0(a1,d7.w)    ;save the fx numbers
  328.         clr.b    d4        ;d4 is a flag: if set, instr. is
  329.         btst    #7,d5        ;in range G-V. If clr, it's 1-F.
  330.         beq.s    nogtov        ;In the song, if bit #7 is set in
  331.         bclr    #7,d5        ;note number byte, it's G-V
  332.         st.b    d4        ;this instrument is in range G-V
  333. nogtov:        move.w    #$f000,d0
  334.         and.w    d6,d0        ;d0 now contains only the # of instr
  335.         bne.s    instnum        ;instrument number is not 0
  336.         tst.b    d4        ;maybe it's G (instr. #0, d4 set)
  337.         beq.s    noinstnum    ;no. It's 0!!!
  338. instnum:    lsr.w    #8,d0        ;shift it right to get number 0-F
  339.         lsr.b    #4,d0
  340.         tst.b    d4
  341.         beq.s    nogtov2
  342.         add.w    #16,d0        ;if G-V, add 16 to the number
  343. nogtov2:    lea    previnstr(pc),a1
  344.         move.b    d0,0(a1,d7.w) ;remember instr. number!
  345.         lea    prevvol(pc),a1
  346.         add.w    #1284,d0    ;offset of volumes in song struct
  347.         move.b    0(a4,d0.w),0(a1,d7.w)    ;vol of this instr to prevvol
  348. noinstnum:    move.w    d6,d0        ;effect again...
  349.         lsr.w    #8,d0
  350.         and.b    #$0f,d0        ;now check only the effect part
  351.         lea    effect(pc),a1
  352.         move.b    d0,0(a1,d7.w)    ;save the effect number
  353.         beq.s    noeffect    ;no effect
  354.         cmp.b    #$0f,d0        ;yes effect...is it Tempo???
  355.         bne.s    not0f        ;not Tempo
  356.         tst.b    d6        ;Tempo !!!
  357.         beq.s    fx0fchgblck    ;if effect qualifier (last 2 #'s)..
  358.         cmp.b    #$f0,d6        ;..is zero, go to next block
  359.         bhi.s    fx0fspecial    ;if it's F1-FF something special
  360.         clr.l    d0        ;will happen!!!
  361.         move.b    d6,d0
  362.         bsr    _SetTempo    ;change The Tempo
  363.         bra.s    noeffect
  364. fx0fspecial:    cmp.b    #$f2,d6    ; | rest - play | SpecialFX#2: no note..yet
  365.         bne.s    isfxfe    ;not SpecFX2
  366.         move.b    d5,(a3)    ;Yes!!! Save the note number
  367.         clr.w    d5    ; clear the number for awhile
  368.         bra.s    noeffect
  369. isfxfe:        cmp.b    #$fe,d6
  370.         bne.s    noeffect
  371.         clr.w    _soittotila
  372.         or.b    #2,_specialupd
  373.         bra.s    noeffect
  374. fx0fchgblck:    st.b    nextblock    ;next block????...YES!!!! (F00)
  375.         bra.s    noeffect
  376. not0f:        cmp.b    #$0c,d0        ;new volume???
  377.         bne.s    noeffect    ;NO!!!!!!!!!!!!!!!!!!!!!!
  378.         move.b    d6,d0
  379.         lsr.b    #4,d0        ;Strange code begins now
  380.         mulu    #10,d0
  381.         move.b    d6,d1
  382.         and.b    #$0f,d1
  383.         add.b    d1,d0        ;strange code ends now: d0 is vol
  384.         cmp.b    #64,d0
  385.         bls.s    novolov64
  386.         moveq.l    #64,d0
  387. novolov64    lea    prevvol(pc),a1
  388.         move.b    d0,0(a1,d7.w)    ;and save it....
  389. noeffect:    tst.b    d5    ;Now we'll check if we have to play a note
  390.         beq.s    endtrkloop    ;no.
  391.         move.b    d5,(a3)
  392.         move.w    d7,d0
  393.         move.w    d5,d1
  394.         clr.w    d2
  395.         clr.w    d3
  396.         lea    previnstr(pc),a1
  397.         move.b    0(a1,d7.w),d3
  398.         lea    prevvol(pc),a1
  399.         move.b    0(a1,d7.w),d2    ;get volume
  400.         bsr    _SoitaNuotti    ;play it!!!!!!!!!!!
  401. endtrkloop:    addq.l    #1,a3        ;a3 = pointer to prev. note #
  402.         addq.l    #1,d7
  403.         cmp.w    numtracks,d7
  404.         blt.w    trloop0
  405.  
  406.         add.w    #1,_soittorivi    ;very important!!! advance line!!
  407.         cmp.w    #63,_soittorivi    ;important too!!! advance block??
  408.         bgt.s    chgblock    ;yes!!!
  409.         tst.b    nextblock    ;command F00 ??
  410.         beq.s    nochgblock    ;no, don't change block
  411. chgblock:    clr.w    _soittorivi    ;clear line number
  412.         cmp.w    #2,_soittotila    ;play block or play song
  413.         bne.s    nonewseq    ;play block only...
  414.         add.w    #1,_soittolohkonnum    ;advance sequence number
  415.         move.w    1546(a4),d0    ;get the highest seq number
  416.         move.w    _soittolohkonnum,d1    ;and current seq number
  417.         cmp.w    d0,d1    ;is this the highest seq number
  418.         blt.s    nostartagain    ;no
  419.         clr.w    _soittolohkonnum    ;yes: play song again
  420.         clr.w    d1            ;...forever!!!
  421. nostartagain:    clr.w    d0
  422.         lea    1446(a4),a1    ;offset of sequence table
  423.         move.b    0(a1,d1.w),d0    ;get number of the block
  424.         move.w    d0,_soittolohko    ;and put it to block number var
  425.         move.w    _lohkoja,d1    ;get number of blocks
  426.         subq.w    #1,d1        ;# of blocks-1 = # of highest block
  427.         cmp.w    d1,d0        ;is this block number too big
  428.         blt.s    nonewseq    ;no
  429.         move.w    d1,_soittolohko    ;yes..then play just the last block
  430. nonewseq:    clr.b    nextblock    ;clear this if F00 set it
  431. nochgblock:    tst.w    _naytonpaivitys    ;screen updating on??
  432.         beq.s    nonewnote    ;no
  433.         movea.l    _maintsk,a1    ;ask the main task to update screen
  434.         move.l    _nayttomsk,d0
  435.         jsr    -$144(a6)    ;Signal()
  436. nonewnote:
  437. ;    *********************** This code produces the effects **
  438.         clr.l    d7    ;clear track count
  439.         lea    prevper(pc),a3
  440.         lea    prevvol(pc),a4
  441. trloop1:    clr.w    d5
  442.         lea    effect,a1
  443.         clr.w    d4
  444.         move.b    0(a1,d7.w),d6    ;get the fx number
  445.         lea    effectqual,a1
  446.         move.b    0(a1,d7.w),d4    ;and the last 2 #'s
  447.         lea    prevmidinote,a0    ;first: is it MIDI??
  448.         tst.b    0(a0,d7.w)
  449.         bne.w    midifx
  450.         cmp.b    #1,d6        ;effect #1
  451.         bne.s    nofx01
  452. ;    **************************************** Effect 01 ******
  453.         cmp.w    #5,_tamakappale+1552
  454.         bne.s    nost1
  455.         tst.b    _counter
  456.         beq    newvals
  457. nost1:        sub.w    d4,(a3)    ;slide it up!!!
  458.         cmp.w    #113,(a3)    ;too high???
  459.         bge    newvals
  460.         move.w    #113,(a3)    ;yes, too high!!!
  461.         bra    newvals
  462. ;    *********************************************************
  463. nofx01:        cmp.b    #2,d6
  464.         bne.s    nofx02
  465. ;    **************************************** Effect 02 ******
  466.         cmp.w    #5,_tamakappale+1552
  467.         bne.s    nost2
  468.         tst.b    _counter
  469.         beq    newvals
  470. nost2:        add.w    d4,(a3)    ;slide it down!!!!!!!!!
  471.         cmp.w    #856,(a3)    ;too low??
  472.         ble    newvals
  473.         move.w    #856,(a3)    ;too low.
  474.         bra    newvals
  475. ;    *********************************************************
  476. nofx02:        tst.b    d6
  477.         bne.s    nofx00
  478. ;    **************************************** Effect 00 ******
  479.         tst.b    d4    ;both fxqualifiers are 0s: no arpeggio!!
  480.         beq.w    endl
  481.         lea    prevnote,a1
  482.         bsr.w    DoArpeggio
  483.         subq.b    #1,d4        ;-1 to make it 0 - 127
  484.         add.b    _tamakappale+1550,d4    ;add play transpose
  485.         lsl.b    #1,d4        ;shift to make index for UWORD
  486.         lea    _periodit,a1
  487.         move.w    0(a1,d4.w),d5
  488.         bra.w    newvals
  489. ;    *********************************************************
  490. nofx00:        cmp.b    #$0d,d6
  491.         bne.s    nofx0d
  492. ;    **************************************** Effect 0D ******
  493.         move.b    d4,d1
  494.         move.b    (a4),d0    ;move previous vol to d0
  495.         and.b    #$f0,d1
  496.         bne.s    crescendo
  497.         sub.b    d4,d0    ;sub from prev. vol
  498.         bpl.s    novolund0
  499.         clr.b    d0    ;volumes under zero not accepted!!!
  500. novolund0:    move.b    d0,(a4)    ;put new vol back
  501.         bra    newvals
  502. crescendo:    lsr.b    #4,d1
  503.         add.b    d1,d0
  504.         cmp.b    #64,d0
  505.         ble.s    novolover64
  506.         moveq.l    #64,d0
  507. novolover64:    move.b    d0,(a4)
  508.         bra    newvals
  509. ;    *********************************************************
  510. nofx0d:        cmp.b    #3,d6
  511.         bne.s    nofx03
  512. ;    **************************************** Effect 03 ******
  513.         move.w    (a3),d5    ;this is very simple: get the old period
  514.         cmp.b    #3,_counter    ;and..
  515.         bge.w    newvals        ;if counter < 3
  516.         sub.w    d4,d5    ;subtract effect qualifier
  517.         bra.w    newvals
  518. ;    *********************************************************
  519. nofx03:        cmp.b    #$0f,d6
  520.         bne.s    nofx0f
  521. ;    **************************************** Effect 0F ******
  522. fx0f:        cmp.b    #$ff,d4
  523.         bne.s    no0fff
  524.         move.w    d7,d0
  525.         bsr.w    _ChannelOff
  526.         bra.w    endl
  527. no0fff:        cmp.b    #$f1,d4
  528.         bne.s    no0ff1
  529.         cmp.b    #3,_counter
  530.         bne.s    newvals
  531.         bra.s    playfxnote
  532. no0ff1:        cmp.b    #$f2,d4
  533.         bne.s    no0ff2
  534.         cmp.b    #3,_counter
  535.         bne.s    newvals
  536.         bra.s    playfxnote
  537. no0ff2:        cmp.b    #$f3,d4
  538.         bne.s    endl
  539.         move.b    _counter,d0
  540.         and.b    #2+4,d0        ;is 2 or 4
  541.         beq.s    newvals
  542. playfxnote:    move.w    d7,d0        ;track # to d0...
  543.         lea    prevnote(pc),a1
  544.         clr.w    d1
  545.         move.b    0(a1,d7.w),d1    ;get note # of previous note
  546.         clr.w    d2
  547.         move.b    (a4),d2        ;get previous volume
  548.         lea    previnstr(pc),a1
  549.         clr.w    d3
  550.         move.b    0(a1,d7.w),d3
  551.         bsr    _SoitaNuotti
  552.         bra.s    endl
  553. ;    *********************************************************
  554. nofx0f:        cmp.b    #$0e,d6
  555.         bne.s    nofx0e
  556. fx0e:        or.b    #1,_specialupd
  557.         tst.b    d4
  558.         bne.s    filteroff
  559.         bclr    #1,$bfe001
  560.         bra.s    endl
  561. filteroff:    bset    #1,$bfe001
  562.         bra.s    endl
  563. nofx0e:        cmp.b    #$0c,d6
  564.         bne.s    endl
  565. newvals:    tst.w    d5    ;now: do the effects!!!
  566.         bne.s    nonewper
  567.         move.w    (a3),d5    ;no new period specified: get the old
  568. nonewper:    move.w    d7,d4    ;channel number to d4
  569.         lsl.w    #2,d4    ;and shift it to make it a longword index
  570.         lea    audaddr,a1
  571.         movea.l    0(a1,d4.w),a1
  572.         move.w    d5,ac_per(a1)
  573.         clr.w    d5
  574.         move.b    (a4),d5
  575.         move.w    d5,ac_vol(a1)
  576. endl:        addq.l    #2,a3    ;inc pointer to previous period value
  577.         addq.l    #1,a4    ;and previous volume
  578.         addq.l    #1,d7    ;increment channel number
  579.         cmp.w    numtracks,d7    ;all channels done???
  580.         blt.w    trloop1    ;not yet!!!
  581.  
  582.         bsr    _StartDMA    ;turn on DMA
  583.         move.b    _tamakappale+1551,d0    ;get the flags
  584.         btst    #1,d0        ;is Topi's jumping on ???
  585.         beq.w    exitint        ;no
  586.         btst    #2,d0        ;every 8th note ???
  587.         beq.s    no8th
  588.         move.w    #$0007,d0
  589.         and.w    _soittorivi,d0    ;is this 8th note ??
  590.         bne.s    no8th        ;no...
  591.         tst.b    animcnt
  592.         bne.s    no8th
  593.         tst.w    _soittotila
  594.         beq.s    no8th
  595.         move.b    #1,animcnt
  596. no8th:        tst.b    animcnt
  597.         beq.s    exitint
  598.         add.b    #1,animpause    ;Handles all animation
  599.         cmp.b    #2,animpause
  600.         blt.s    exitint
  601.         cmp.b    #10,animcnt
  602.         bne.s    nojumpend
  603.         clr.b    animcnt
  604.         move.b    #1,animpause
  605.         bra.s    exitint
  606. nojumpend:    clr.w    d0
  607.         move.b    animcnt,d0
  608.         add.b    #1,animcnt
  609.         lsl.w    #2,d0
  610.         lea    frame(pc),a1
  611.         move.l    0(a1,d0.w),_sprptr
  612.         tst.w    _naytonpaivitys
  613.         beq.s    exitint
  614. sigjump:    movea.l    _maintsk,a1    ;and asks the main task to...
  615.         move.l    _hyppymsk,d0    ;...SetPointer() !!!!!
  616.         jsr    -$144(a6)    ;Signal()
  617.         clr.b    animpause
  618. exitint:    movem.l    (sp)+,d2-d7/a2-a4
  619.         rts
  620. _SetTempo:    move.w    d0,_tempo
  621.         cmp.b    #10,d0    ;If tempo <= 10, use SoundTracker tempo
  622.         bhi.s    calctempo
  623.         lea    sttempo(pc),a1
  624.         lsl.w    #1,d0
  625.         move.w    0(a1,d0.w),d1
  626.         bra.s    pushtempo
  627. calctempo:    move.l    #470000,d1
  628.         divu    d0,d1
  629. pushtempo:    move.b    d1,$bfe401    ;and set the CIA timer
  630.         lsr.w    #8,d1
  631.         move.b    d1,$bfe501
  632.         or.b    #4,_specialupd
  633.         rts    ; vv-- These values are the SoundTracker tempos (approx.)
  634. sttempo:    dc.w    $0f00,2417,4833,7250,9666,12083,14500,16916,19332,21436,24163
  635.  
  636. midifx:        cmp.b    #1,d6
  637.         bne.s    nomidi01fx
  638.         lea    prevmidichan,a1
  639.         lea    prevpitchbend,a0
  640.         clr.w    d1
  641.         move.b    0(a1,d7.w),d1    ;get previous midi channel
  642.         lsl.w    #1,d1        ;UWORD index
  643.         tst.b    d4        ;x100??
  644.         beq.s    resetpbend
  645.         move.w    0(a0,d1.w),d0    ;get previous pitch bend
  646.         lsl.w    #3,d4        ;multiply bend value by 8
  647.         add.w    d4,d0
  648.         cmp.w    #$3fff,d0
  649.         bls.s    bendpitch
  650.         move.w    #$3fff,d0
  651. bendpitch:    move.w    d0,0(a0,d1.w)    ;save current pitch bend
  652.         lsr.b    #1,d1        ;back to UBYTE
  653.         or.b    #$e0,d1
  654.         lea    noteondata,a0
  655.         move.b    d1,(a0)        ;midi command & channel
  656.         move.b    d0,1(a0)    ;lower value
  657.         and.b    #$7f,1(a0)    ;clear bit 7
  658.         lsr.w    #7,d0
  659.         and.b    #$7f,d0        ;clr bit 7
  660.         move.b    d0,2(a0)    ;higher 7 bits
  661.         moveq.l    #3,d0
  662.         bsr.w    _AddMIDIData
  663.         bra.w    endl
  664. nomidi01fx:    cmp.b    #2,d6
  665.         bne.s    nomidi02fx
  666.         lea    prevmidichan,a1
  667.         lea    prevpitchbend,a0
  668.         clr.w    d1
  669.         move.b    0(a1,d7.w),d1
  670.         lsl.w    #1,d1
  671.         tst.b    d4
  672.         beq.s    resetpbend    ;x200??
  673.         move.w    0(a0,d1.w),d0
  674.         lsl.w    #3,d4
  675.         sub.w    d4,d0
  676.         bpl.s    bendpitch    ;not under 0
  677.         clr.w    d0
  678.         bra.s    bendpitch
  679. nomidi02fx:    cmp.b    #$0f,d6
  680.         beq.w    fx0f
  681.         cmp.b    #$0e,d6
  682.         bne.w    endl
  683.         bra.w    fx0e
  684. resetpbend:    tst.b    _counter
  685.         bne.w    endl
  686.         move.w    #$2000,d0
  687.         bra.s    bendpitch
  688.  
  689. DoArpeggio:    ; beginning note table in a1, note num returned in d4
  690.         move.b    0(a1,d7.w),d1    ;d1 = # of previous note played
  691.         move.b    _counter,d0
  692.         tst.b    d0
  693.         beq.s    arpg03
  694.         cmp.b    #3,d0
  695.         bne.s    arpgn03
  696. arpg03:        and.b    #$0f,d4        ;counter = 0 or 3: get last number
  697.         add.b    d1,d4        ;add it to note number
  698.         rts
  699. arpgn03:    cmp.b    #1,d0
  700.         beq.s    arpg14
  701.         cmp.b    #4,d0
  702.         bne.s    arpgn14
  703. arpg14:        lsr.b    #4,d4    ;counter = 1 or 4: get the first number
  704.         add.b    d1,d4    ;add to prev. note
  705.         rts
  706. arpgn14:    move.b    d1,d4    ;2 or 5: the previous note
  707.         rts
  708.  
  709. getinsdata:    clr.l    d2
  710.         move.w    4(a0),d0    ;Soitin-struct in a0, instr#<<1: d3
  711.         bne.s    iff5or3oct    ;note # in d1 (0 - ...)
  712.         move.l    a0,d0
  713.         lea    _periodit,a0
  714.         lsl.b    #1,d1
  715.         move.w    0(a0,d1.w),d5 ;put period to d5
  716.         move.l    d0,a0
  717.         addq.l    #6,d0        ;Skip structure
  718.         move.l    (a0),d1        ;length
  719.         lea    _tamakappale+1316,a0
  720.         move.w    0(a0,d3.w),d2
  721.         move.w    64(a0,d3.w),d3
  722.         rts
  723. iff5or3oct:    movem.l    a1/d6-d7,-(sp)
  724.         clr.l    d7
  725.         move.w    d1,d7
  726.         divu    #12,d7    ;octave #
  727.         move.l    d7,d5
  728.         swap    d5    ;note number in this oct (0-11) is in d5
  729.         move.l    (a0),d1
  730.         cmp.b    #2,d0
  731.         bne.s    no3oct
  732.         addq.l    #6,d7
  733.         divu    #7,d1    ;get length of the 1st octave
  734.         bra.s    no5oct
  735. no3oct:        divu    #31,d1    ;get length of the 1st octave (5 octaves)
  736. no5oct:        move.l    d1,d0        ;d0 and d1 = length of the 1st oct
  737.         lea    _tamakappale+1316,a1
  738.         move.w    0(a1,d3.w),d2
  739.         move.w    64(a1,d3.w),d3
  740.         clr.w    d6
  741.         move.b    shiftcnt(pc,d7.w),d6
  742.         lsl.w    d6,d2
  743.         lsl.w    d6,d3
  744.         lsl.w    d6,d1
  745.         move.b    mullencnt(pc,d7.w),d6
  746.         mulu    d6,d0        ;offset of this oct from 1st oct
  747.         add.l    a0,d0        ;add base address to offset
  748.         addq.l    #6,d0        ;skip structure
  749.         lea    _periodit,a1
  750.         add.b    octstart(pc,d7.w),d5
  751.         lsl.b    #1,d5
  752.         move.w    0(a1,d5.w),d5
  753.         movem.l    (sp)+,a1/d6-d7
  754.         rts    ;returns period in d5
  755. shiftcnt:    dc.b    4,3,2,1,1,0,2,2,1,1,0,0
  756. mullencnt:    dc.b    15,7,3,1,1,0,3,3,1,1,0,0
  757. octstart:    dc.b    12,12,12,12,24,24,0,12,12,24,24,36
  758.  
  759.         xref    _ciaaresource
  760.         xref    _maintsk
  761.  
  762. _AudioInit:    movem.l    a6/d2,-(sp)
  763.         clr.l    d2
  764.         movea.l    4,a6
  765. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ alloc signal bit
  766.         addq.l    #1,d2
  767.         st.l    d0    ; -1
  768.         jsr    -$14a(a6)    ;AllocSignal()
  769.         tst.b    d0
  770.         bmi.w    initerr
  771.         move.b    d0,sigbitnum
  772. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ prepare IORequest
  773.         lea    allocport(pc),a1
  774.         move.b    d0,15(a1)    ;set mp_SigBit
  775.         move.l    _maintsk,16(a1)    ;set mp_SigTask
  776.         lea    reqlist(pc),a0
  777.         move.l    a0,(a0)        ;NEWLIST begins...
  778.         addq.l    #4,(a0)
  779.         clr.l    4(a0)
  780.         move.l    a0,8(a0)    ;NEWLIST ends...
  781. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ open audio.device
  782.         addq.l    #1,d2
  783.         lea    allocreq(pc),a1
  784.         lea    audiodevname(pc),a0
  785.         clr.l    d0
  786.         clr.l    d1
  787.         movea.l    4,a6
  788.         jsr    -$1bc(a6)    ;OpenDevice()
  789.         tst.b    d0
  790.         bne.s    initerr
  791.         st.b    audiodevopen
  792. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ open ciaa.resource
  793.         addq.l    #1,d2
  794.         clr.l    d0
  795.         lea    ciaaname(pc),a1
  796.         jsr    -$1f2(a6)    ;OpenResource()
  797.         tst.l    d0
  798.         beq.s    initerr
  799.         move.l    d0,_ciaaresource
  800. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ attach interrupt
  801.         addq.l    #1,d2
  802.         move.l    d0,a6
  803.         lea    timerinterrupt(pc),a1
  804.         clr.l    d0    ;Bit number 0: Timer A
  805.         jsr    -$6(a6)    ;AddICRVector
  806.         tst.l    d0
  807.         bne.s    initerr
  808.         and.b    #%10000000,$bfee01
  809.         move.l    #%10000001,d0
  810.         jsr    -$12(a6)    ;AbleICR()
  811.         st.b    timeropen
  812.         clr.w    _soittotila
  813.         clr.l    d0
  814. initret:    movem.l    (sp)+,a6/d2
  815.         rts
  816. initerr:    move.l    d2,d0
  817.         bra.s    initret
  818.  
  819. _AudioRem:    move.l    a6,-(sp)
  820.         tst.b    timeropen
  821.         beq.s    rem1
  822. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ remove interrupt
  823.         move.l    _ciaaresource,a6
  824.         lea    timerinterrupt(pc),a1
  825.         clr.l    d0    ;Bit number 0: Timer A
  826.         jsr    -$c(a6)        ;RemICRVector
  827. ;There is no CloseResource(). I'm not sure if I should use CloseLibrary()??
  828. rem1:        movea.l    4,a6
  829.         tst.b    audiodevopen
  830.         beq.s    rem2
  831.         move.w    #$000f,$dff096    ;stop audio DMA
  832. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ close audio.device
  833.         lea    allocreq(pc),a1
  834.         jsr    -$1c2(a6)    ;CloseDevice()
  835. rem2:        clr.l    d0
  836.         move.b    sigbitnum,d0
  837.         bmi.s    rem3
  838. ;    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ free signal bit
  839.         jsr    -$150(a6)    ;FreeSignal()
  840. rem3:        move.l    (sp)+,a6
  841.         rts
  842.  
  843. _GetSerial:    move.l    a6,-(sp)    ;Get serial port for MIDI
  844.         move.l    4,a6
  845.         clr.l    d0
  846.         lea    miscresname(pc),a1
  847.         jsr    -$1f2(a6)    ;OpenResource()
  848.         move.l    d0,miscresbase
  849.         tst.l    d0
  850.         beq.s    gserror
  851.         move.l    d0,a6
  852.         lea    medname(pc),a1
  853.         clr.l    d0        ;serial port
  854.         jsr    -$6(a6)        ;AllocMiscResource()
  855.         tst.l    d0
  856.         bne.s    gserror
  857.         st.b    serportalloc
  858.         moveq.l    #0,d0        ;TBE
  859.         lea    serinterrupt(pc),a1
  860.         move.l    4,a6
  861.         jsr    -$a2(a6)    ;SetIntVector()
  862.         move.l    d0,prevtbe
  863.         moveq.l    #11,d0        ;RBF
  864.         lea    rbfinterrupt(pc),a1
  865.         jsr    -$a2(a6)    ;SetIntVector()
  866.         move.l    d0,prevrbf
  867.         move.w    #$8001,$dff09a    ;TBE on!!
  868.         move.w    #114,$dff032    ;set baud rate (SERPER)
  869.         clr.l    d0
  870. retgs:        move.l    (sp)+,a6
  871.         rts
  872. gserror:    st    d0
  873.         bra.s    retgs
  874.  
  875. _FreeSerial:    move.l    a6,-(sp)
  876.         tst.l    miscresbase
  877.         beq.s    retfs
  878.         tst.b    serportalloc
  879.         beq.s    retfs
  880.         move.w    #$0801,$dff09a    ;disable RBF & TBE
  881.         movea.l    prevtbe(pc),a1
  882.         moveq.l    #0,d0
  883.         movea.l    4,a6
  884.         jsr    -$a2(a6)    ;SetIntVector()
  885.         movea.l    prevrbf(pc),a1
  886.         moveq.l    #11,d0
  887.         jsr    -$a2(a6)    ;SetIntVector()
  888.         movea.l    miscresbase(pc),a6
  889.         clr.l    d0        ;serial port
  890.         jsr    -$c(a6)        ;FreeMiscResource()
  891.         clr.b    serportalloc
  892. retfs:        move.l    (sp)+,a6
  893.         rts
  894.  
  895. prevtbe:    dc.l    0
  896. prevrbf:    dc.l    0        
  897.         xref    _recmidi
  898.         xref    _recmidimsk
  899.  
  900. RBFIntHandler:    move.w    $18(a0),d0    ;SERDATR
  901.         move.w    #$0800,$9c(a0)    ;clr intreq
  902.         btst    #7,d0        ;status??
  903.         beq.s    nostatus
  904.         move.b    d0,(a1)
  905.         move.b    #$1,3(a1)
  906.         rts
  907. nostatus:    clr.w    d1
  908.         move.b    3(a1),d1
  909.         move.b    d0,0(a1,d1.w)
  910.         addq.b    #1,d1
  911.         cmp.b    #3,d1
  912.         bge.s    sigmidirec
  913.         move.b    d1,3(a1)
  914.         rts
  915. sigmidirec:    move.b    #$1,3(a1)
  916.         and.b    #$f0,(a1)
  917.         cmp.b    #$90,(a1)
  918.         bne.s    nosrec
  919.         move.b    1(a1),_recmidi
  920.         movea.l    _maintsk,a1
  921.         move.l    _recmidimsk,d0
  922.         jsr    -$144(a6)    ;Signal()
  923. nosrec:        rts
  924. recmidi:    dc.b    0,0,0,0
  925.         
  926. SerIntHandler:    move.w    #1,$9c(a0)    ;clear intreq bit
  927.         clr.l    d0
  928.         move.b    bytesinbuff(pc),d0
  929.         beq.s    exsih        ;buffer empty
  930.         move.w    #$100,d1    ;Stop bit
  931.         move.b    sendbuffer(pc),d1
  932.         move.w    d1,$30(a0)    ;SERDAT
  933.         move.w    #$4000,$9a(a0) ;NO ONE may stop us!!!
  934.         addq.b    #1,$126(a6)
  935.         lea    sendbuffer(pc),a5
  936. shiftdataloop:    subq.b    #1,d0        ;shift serial buffer 1 byte left
  937.         beq.s    endshiftloop
  938.         move.b    (a1)+,(a5)+    ;a1 = is_Data = sendbuffer + 1
  939.         bra.s    shiftdataloop
  940. endshiftloop:    subq.b    #1,bytesinbuff
  941.         subq.b    #1,$126(a6)
  942.         bge.s    exsih
  943.         move.w    #$c000,$9a(a0)
  944. exsih:        rts
  945.  
  946. _AddMIDIData:    tst.b    serportalloc
  947.         beq.s    retamd
  948.         movem.l    d2/a6,-(sp)
  949.         movea.l    4,a6
  950.         move.w    #$4000,$dff09a    ;No interrupts...
  951.         addq.b    #1,$126(a6)
  952.         clr.w    d1
  953.         clr.b    d2
  954.         move.b    bytesinbuff(pc),d1
  955.         seq.b    d2
  956.         add.b    d0,d1
  957.         cmp.b    #127,d1
  958.         bgt.s    overflow    ;sorry, can't do anything.
  959.         move.b    d1,bytesinbuff
  960.         sub.b    d0,d1
  961.         lea    sendbuffer(pc,d1.w),a1
  962. adddataloop:    move.b    (a0)+,(a1)+
  963.         subq.b    #1,d0
  964.         bne.s    adddataloop
  965. overflow:    subq.b    #1,$126(a6)
  966.         bge.s    nointena
  967.         move.w    #$c000,$dff09a
  968. nointena:    tst.b    d2
  969.         beq.s    nonewtbe
  970.         move.w    #$8001,$dff09c    ;request TBE
  971. nonewtbe:    movem.l    (sp)+,d2/a6
  972. retamd:        rts
  973.  
  974. sendbuffer:    ds.b    128
  975. miscresbase:    dc.l    0
  976. noteondata:    dc.l    0
  977. audiodevopen:    dc.b    0
  978. timeropen:    dc.b    0
  979. serportalloc:    dc.b    0
  980. bytesinbuff:    dc.b    0
  981. preschgdata:    dc.b    0,0
  982. pbendresdata:    dc.b    $e0,$00,$40 ;for fast pitch bend resetting
  983. sigbitnum:    dc.b    -1
  984. timerinterrupt:    dc.w    0,0,0,0,0
  985.         dc.l    timerintname,0,_IntHandler
  986. serinterrupt:    dc.w    0,0,0,0,0
  987.         dc.l    serintname,sendbuffer+1,SerIntHandler
  988. rbfinterrupt:    dc.w    0,0,0,0,0
  989.         dc.l    rbfintname,recmidi,RBFIntHandler
  990. allocport:    dc.l    0,0    ;succ, pred
  991.         dc.b    4,0    ;NT_MSGPORT
  992.         dc.l    0    ;name
  993.         dc.b    0,0    ;flags = PA_SIGNAL
  994.         dc.l    0    ;task
  995. reqlist:    dc.l    0,0,0    ;list head, tail and tailpred
  996.         dc.b    5,0
  997. allocreq:    dc.l    0,0
  998.         dc.b    5,127    ;NT_MESSAGE, maximum priority (127)
  999.         dc.l    0,allocport    ;name, replyport
  1000.         dc.w    68        ;length
  1001.         dc.l    0    ;io_Device
  1002.         dc.l    0    ;io_Unit
  1003.         dc.w    0    ;io_Command
  1004.         dc.b    0,0    ;io_Flags, io_Error
  1005.         dc.w    0    ;ioa_AllocKey
  1006.         dc.l    sttempo    ;ioa_Data
  1007.         dc.l    1    ;ioa_Length
  1008.         dc.w    0,0,0    ;ioa_Period, Volume, Cycles
  1009.         dc.w    0,0,0,0,0,0,0,0,0,0    ;ioa_WriteMsg
  1010. ciaaname:    dc.b    'ciaa.resource',0
  1011. timerintname:    dc.b    'MEDTimerInterrupt',0
  1012. serintname:    dc.b    'MEDSerialInterrupt',0
  1013. rbfintname:    dc.b    'MEDSerialRBFInt',0
  1014. audiodevname:    dc.b    'audio.device',0
  1015. miscresname:    dc.b    'misc.resource',0
  1016. medname:    dc.b    'MED',0 ;yeah, our name
  1017.         end
  1018.